var t,
  a = require("../../res/www.a9a.cn.js"),
  e = getApp();
Page({
  data: {
    vobj: "",
    light_old: "",
    color: "",
    miao: 8,
    btn5startflag: !0,
    tips3flag: !0,
    cartoonflag: !1,
  },
  onLoad: function (t) {
    var o = this,
      n = t.truename,
      i = t.identitynum;
    e.chklogin().then(function (t) {
      t || wx.navigateBack();
    }),
      e.ajax({
        url: "get_config.php",
        data: { f: "_ZEAI", ver: 10 },
        success: function (t) {
          wx.setStorageSync("COOK_ZEAI", {
            ifps: t.ifps,
            siteName: t.siteName,
            color: t.color,
            loveb: t.loveb,
            cache_str: t.cache_str,
            tabbar: t.tabbar,
          }),
            o.setData({
              ifps: t.ifps,
              color: t.color,
              rgbcolor: a.c16_rgb(t.color),
              siteName: t.siteName,
              WWW: e.WWW,
              cache_str: t.cache_str,
              truename: n,
              identitynum: i,
            });
        },
      }),
      (this.vobj = wx.createCameraContext()),
      wx.getScreenBrightness({
        success: function (t) {
          o.setData({ light_old: t.value }),
            setTimeout(function () {
              wx.setScreenBrightness({ value: 0.8 });
            }, 1e3);
        },
      }),
      (!a.empty(n) && a.ifsfz(i)) ||
        wx.showModal({
          content: "姓名或身份证号不能为空",
          confirmColor: o.data.color,
          confirmText: "朕知道了",
          showCancel: !1,
          success: function (t) {
            wx.navigateBack();
          },
        });
  },
  backFn: function () {
    wx.navigateBack(), wx.setScreenBrightness({ value: this.data.light_old });
  },
  startRecord: function () {
    var t = this;
    this.vobj.startRecord({
      success: function (t) {
        console.log("startRecord");
      },
    }),
      t.setData({ btn5startflag: !1, tips3flag: !1, cartoonflag: !0 }),
      (t.time = setInterval(function () {
        t.setData({ miao: t.data.miao - 1 }),
          0 == t.data.miao && (clearInterval(t.time), t.stopRecord());
      }, 1e3));
  },
  stopRecord: function () {
    var o = this,
      n = this;
    this.vobj.stopRecord({
      success: function (i) {
        o.setData({ src: i.tempThumbPath, videoSrc: i.tempVideoPath }),
          wx.showLoading({ title: "正在活体检测..." }),
          (t = wx.getStorageSync("COOK_U"));
        var s = {
          submitok: "face_update",
          truename: n.data.truename,
          identitynum: n.data.identitynum,
          openid: t.openid,
        };
        wx.uploadFile({
          url: e.WWW + "/api/wxxcx/my_cert.php",
          filePath: n.data.videoSrc,
          name: "video",
          formData: s,
          success: function (t) {
            (t = a.jsoneval(t.data)),
              wx.hideLoading(),
              wx.showLoading({ title: "正在进行公安库验证中..." }),
              1 == t.flag
                ? wx.uploadFile({
                    url: e.WWW + "/api/wxxcx/my_cert.php",
                    filePath: n.data.src,
                    name: "pic",
                    formData: s,
                    success: function (t) {
                      wx.hideLoading(),
                        1 == (t = a.jsoneval(t.data)).flag
                          ? (wx.showToast({
                              title: t.msg,
                              mask: !0,
                              duration: 3e3,
                            }),
                            setTimeout(function () {
                              wx.navigateBack({ delta: 2 });
                            }, 3e3))
                          : wx.showModal({
                              content: t.msg,
                              confirmColor: n.data.color,
                              confirmText: "朕知道了",
                              showCancel: !1,
                              success: function (t) {
                                wx.navigateBack();
                              },
                            });
                    },
                  })
                : wx.showModal({
                    content: t.msg,
                    confirmColor: n.data.color,
                    confirmText: "朕知道了",
                    showCancel: !1,
                    success: function (t) {
                      wx.navigateBack();
                    },
                  });
          },
        });
      },
    });
  },
  errorFn: function () {
    wx.navigateBack(), wx.setScreenBrightness({ value: this.data.light_old });
  },
  onHide: function () {
    wx.setScreenBrightness({ value: this.data.light_old });
  },
  onUnload: function () {
    wx.setScreenBrightness({ value: this.data.light_old });
  },
});
